package site.marqstree.kotlin.library.good.ui.service

import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.facade.template.IProvider
import io.reactivex.Observable
import site.marqstree.kotlin.library.base.data.net.request.RxRequest
import site.marqstree.kotlin.library.base.extent.json2Bean
import site.marqstree.kotlin.library.good.ui.bean.CartBean
import site.marqstree.kotlin.library.good.ui.bean.GoodDetailBean
import site.marqstree.kotlin.provider.common.ProviderConstant
import java.util.*


/*
 * 项目名: KotlinMall
 * 包名: site.marqstree.kotlin.library.good.ui.service
 * 文件名: GoodService
 * 创建者: marqstree
 * 创建时间: 2020/3/14 12:12
 * 描述: TODO
 */
@Route(path="/good/service")
class GoodService: IProvider {
    lateinit var mContext: Context

    override fun init(context: Context?) {
        mContext = context!!
    }

    fun getGoodDetail(goodId: Int): Observable<GoodDetailBean>{
        return RxRequest.builder()
            .setUrl(ProviderConstant.GOOD_DETAIL_URL)
            .setParam("id",goodId)
            .get()
            .json2Bean(GoodDetailBean::class.java)
    }

    fun getCartList(): Observable<CartBean>{
        return RxRequest.builder()
            .setUrl(ProviderConstant.CART_LIST_URL)
            .get()
            .json2Bean(CartBean::class.java)
    }

}